# coding:utf-8
# 王一舟
# shishi.py


import allure
import jsonpath
import requests
import json

from core.globalContext import g_Context
# 扩展:导入封装的关键字- 注意:导包一般是从根目录的下一层目录开始(除根目录)
from extend.keywords import KeyWords
from tools.varRender import refresh

loginURL = 'http://shop-xo.hctestedu.com/?s=api/user/login'
param = {
    "application": "app",
    "application_client_type": "weixin", }
body = {"accounts": "15921953117", "pwd": "Wyz741852", "type": "username"}
headers = {"content-Type": "application/json"}

re = requests.session()


r = re.post(url=loginURL,params=param,json=body,headers=headers)
print(r.json())

token = jsonpath.jsonpath(r.json(),"$..token",)[0]

print(token)

url_useraddress_index = f'http://shop-xo.hctestedu.com/?s=api/useraddress/index'

param_goods = {
            "token": token,
            "application":"app",
            "application_client_type":"weixin",
        }

request_data = {"url":url_useraddress_index,"params":param_goods}
r = re.post(**request_data,headers=headers)

print(r.json())

id = jsonpath.jsonpath(r.json(),'$.data.data[?(@.alias=="榴莲真好吃")].id')[0]


print(id)



